package com.demo.snowflake.util;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ReflectUtil;
import com.demo.snowflake.annotation.DataTitle;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class DataTitleUtil {

    public static Map<String,String> getDataTitle(Class<?> clazz){
        Assert.notNull(clazz);
        Map<String,String> res = new HashMap<>();
        Field[] fields = ReflectUtil.getFields(clazz);
        for (Field field : fields){
            res.put(field.getName(),field.getAnnotation(DataTitle.class).describe());
        }
        return res;
    }
}
